using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class CastAreaSkillDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            CastAreaSkill data = target as CastAreaSkill;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.skillId = ValueObject.Value<int>(value);
                    break;
                case 2:
                    data.attackCoordinate = (Coordinate) value;
                    break;
                case 3:
                    data.targetCoordinate = (Coordinate) value;
                    break;
                case 4:
                    data.startFame =  ValueObject.Value<long>(value);
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            CastAreaSkill data = target as CastAreaSkill;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return ValueObject.Get(data.skillId);
                case 2:
                    return data.attackCoordinate;
                case 3:
                    return data.targetCoordinate;
                case 4:
                    return ValueObject.Get(data.startFame);
            }

            return null;
        }
    }
}